package com.d0330;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class TestMethod {

    public static void main(String[] args){
        try {
            Class clazz=Method.class;
            Method method= null;
            Account account= null;
            account = (Account)clazz.newInstance();
            method = clazz.getMethod("save",Double.class);
            System.out.println(account.getBalance());
            method.invoke(account,new Double(2000));
            System.out.println(account.getBalance());
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}